﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;
using System.Windows.Data;
using UmlControlLibrary;

namespace UmlControlLibrary
{
    public class UmlDesignerElementSection : DependencyObject, INotifyPropertyChanged
    {
        public static DependencyProperty ElementsProperty = DependencyProperty.Register("Elements", typeof(Binding), typeof(UmlDesignerElementSection));

        public Binding Elements
        {
            get { return (Binding)GetValue(UmlDesignerElementSection.ElementsProperty); }
            set { SetValue(UmlDesignerElementSection.ElementsProperty, value); }
        }

        public void Refresh()
        {
            (Elements.Source as DiagramElement).OnPropertyChanged(Elements.Path.Path);
        }

        public SpecificMenu SpecificMenu
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public UmlDesignerElementSection(string name, string title, string elementsPath, SpecificMenu menu)
        {
            Name = name;
            Title = title;
            Elements = new Binding(elementsPath);
            SpecificMenu = menu;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}
